package com.superman.supermarket.client.view.mycouponlist;

import java.util.List;
import java.util.Map;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Widget;
import com.superman.mvpframe.client.mvp.IPageViewPresenter;
import com.superman.mvpframe.client.widget.pulltorefresh.IPullToRefreshView;
import com.superman.mvpframe.client.widget.pulltorefresh.PullToRefreshViewAbstractImpl;
import com.superman.mvpframe.client.widget.tabbar.MyTabBar;
import com.superman.supermarket.client.composite.mycouponlist.CouponListCellInvalidModule;
import com.superman.supermarket.client.composite.mycouponlist.CouponListCellModule;

/**
 * 我的优惠券列表ui实现类
 * 
 * @author superman
 * @version 2018年8月19日下午9:58:52
 */
public class MyCouponListViewImpl extends PullToRefreshViewAbstractImpl implements MyCouponListView {

	interface MyCouponListViewImplUiBinder extends UiBinder<Widget, MyCouponListViewImpl> {
	}

	private static MyCouponListViewImplUiBinder uiBinder = GWT.create(MyCouponListViewImplUiBinder.class);

	@UiField
	MyTabBar mytabbar;
	private boolean notUsed;
	@UiField
	FlowPanel wrapperpanel, listpanel;

	/**
	 * 构造方法
	 * 
	 * @author superman
	 * @version 2018年8月19日 下午9:58:49
	 */
	public MyCouponListViewImpl() {
		initWidget(uiBinder.createAndBindUi(this));

		mytabbar.addTab("未使用");
		mytabbar.addTab("已失效");
	}

	@Override
	public IPullToRefreshView getPullToRefreshView() {
		return this;
	}

	@Override
	public MyTabBar getTabBar() {
		return mytabbar;
	}

	@Override
	public void init() {
		// TODO Auto-generated method stub

	}

	@Override
	public void setCurrentCouponListNoUsed(boolean notUsed) {
		this.notUsed = notUsed;

	}

	@Override
	public void setDataListDivId(String id) {
		listpanel.getElement().setId(id);
	}

	@Override
	public void setListData(List<Map<String, Object>> list) {
		for (Map<String, Object> map : list) {
			CouponListCellModule couponListCellModule = null;
			if (notUsed) {
				couponListCellModule = new CouponListCellModule();
			} else {
				couponListCellModule = new CouponListCellInvalidModule();
			}
			couponListCellModule.setData(map);
			this.listpanel.add(couponListCellModule);
		}
	}

	@Override
	public void setMeScrollDivId(String id) {
		wrapperpanel.getElement().setId(id);
	}

	@Override
	public void setPageViewPresenter(IPageViewPresenter presenter) {
		// TODO Auto-generated method stub

	}

}
